<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of Plume Framework, a simple PHP Application Framework.
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
#
# Plume Framework is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Plume Framework is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# ***** END LICENSE BLOCK ***** */

/**
 * Custom tag example.
 */
class Pluf_Template_Tag_Mytag extends Pluf_Template_Tag
{
    /**
     * Perform some operations at the opening of the
     * tag {mytag 'param1', 'param2'}.
     *
     * You can access the template context through 
     * $this->context
     */
    function start($param1, $param2)
    {
        echo 'start of tag mytag:<br />';
        echo '$this->context[mytag]: '
            .$this->context->get('mytag').'<br />';
    }
 
    /**
     * Generate some valid PHP code to be put in the template.
     *
     * The code generated by this function is included in the
     * template just after the call to $this->start() if the start()
     * method is implemented.
     *
     * You cannot access the template context but you can write
     * code that is modifying it through $t
     */
    function genStart()
    {
        return '$t->set(\'mytag\', \'hello world!\');';
    }
 
    /**
     * Perform some operations at the closing of the
     * tag {/mytag 'param1'}.
     *
     * You can access the template context through 
     * $this->context
     */
    function end($param1)
    {
        echo 'end of tag mytag:<br />';
        echo '$this->context[mytag]: '
            .$this->context->get('mytag').'<br />';
    }

    /**
     * Generate some valid PHP code to be put in the template.
     *
     * The code generated by this function is included in the
     * template just after the call to $this->end() if the end()
     * method is implemented.
     *
     * You cannot access the template context but you can write
     * code that is modifying it through $t
     */

    function genEnd()
    {
        // Cleaning :)
        return '$t->set(\'mytag\', \'\');';
    }

}
